﻿using UnityEngine;
using System.Collections;

public class CubeGenerator : MonoBehaviour {
    public GameObject m_Cube; 
    public float m_Speed;
	// Use this for initialization
	void Start () {
        createbuce();
	}
    public void createbuce()
    {
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
               GameObject cubo = Instantiate(m_Cube, new Vector3(i, j, 0), Quaternion.identity) as GameObject;
               cubo.transform.parent = transform;
                //    GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                //   cube.transform.position = new Vector3(i, j, 0);
                //   cube.AddComponent<Rigidbody>();
            }
        }
    }

    void OnDestroy()
    {
        int numChilds = transform.GetChildCount();
        for (int i = 0; i < numChilds; i++)
        {
            Destroy(transform.GetChild(i));
        }
    }
    // Update is called once per frame
    void Update()
    {
	
	}
}
